<?php

namespace App\Transformers\User;

use App\Models\User;
use League\Fractal\TransformerAbstract;

class UserDetailsTransformer extends TransformerAbstract
{
    public function transform(User $user)
    {
        return [
            'id' => $user->id,
            'avatar' => $user->avatar ?? '',
            'avatar_url' => 'https://placeimg.com/50/50/any',
            'real_name' => $user->real_name ?? '',
            'nickname' => $user->nickname ?? '',
            'level' => $user->level ?? '',
            'balance' => $user->balance ?? '',
            'integral' => $user->integral ?? '',
            'pay_count' => $user->pay_count ?? '',
            'created_at' => $user->created_at ? $user->created_at->format("Y-m-d H:i:s") : '',
            'CouponIssueUser' => $user->couponissueuser[0]['created_at']->format("Y-m-d H:i:s") ,
        ];
    }
}
